package com.uchiha.nova.mainService.wrapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.uchiha.nova.core.model.entity.ChinaGeoJsonEntity;
import com.uchiha.nova.core.model.vo.ChinaGeoJsonVO;
import com.uchiha.nova.core.tool.support.BaseEntityWrapper;
import com.uchiha.nova.core.tool.util.BeanUtil;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 中国地图的geo数据 包装类,返回视图层所需的字段
 *
 * @author Chill
 */
public class ChinaGeoJsonWrapper extends BaseEntityWrapper<ChinaGeoJsonEntity, ChinaGeoJsonVO>  {

	public static ChinaGeoJsonWrapper build() {
		return new ChinaGeoJsonWrapper();
 	}

	@Override
	public ChinaGeoJsonVO entityVO(ChinaGeoJsonEntity entity) {
		ChinaGeoJsonVO vo = BeanUtil.copy(entity, ChinaGeoJsonVO.class);
		return vo;
	}

	@Override
	public List<ChinaGeoJsonVO> listVO(List<ChinaGeoJsonEntity> list) {
		List<ChinaGeoJsonVO> vos = list.stream().map(item->{
			ChinaGeoJsonVO vo = BeanUtil.copy(item, ChinaGeoJsonVO.class);
			return vo;
		}).collect(Collectors.toList());
		return vos;
	}

	@Override
	public IPage<ChinaGeoJsonVO> pageVO(IPage<ChinaGeoJsonEntity> pages) {
		IPage<ChinaGeoJsonVO> page = pages.convert(item->{
			ChinaGeoJsonVO vo = BeanUtil.copy(item, ChinaGeoJsonVO.class);
	
			return vo;
		});
		return page;
	}
}

